package com.ldj.controller;

import com.ldj.common.SystemMessage;
import com.ldj.model.User;
import com.ldj.service.UserService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 人员Controller
 *
 */

@Controller
@Api(value="UserController",description="测试接口描述")
public class UserController {

    @Autowired
    private UserService userService;

   /* *
     * 根据id查询人员
     * @param id 人员id
     * @return
     **/

    @RequestMapping(value="/user/getUser", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过ID查询USER信息", httpMethod = "GET", notes = "暂无")
    public SystemMessage getUser(@ApiParam(required = true, name = "id", value = "ID")
                                      @RequestParam(value = "id") String id){
        SystemMessage retMsg = new SystemMessage();
        try{
            User user = userService.getUserById(id);
            retMsg.setSuccess("200");
            retMsg.setData(user);
        }catch (Exception e){
            retMsg.setSuccess("300");
            retMsg.setMsg(e.getMessage());
        }
        return retMsg;
    }

}
